import { bg_image } from "./indoorConfig.js";
import {indoorRecordDetail,outdoorRecordDetail,} from "../api/payRecords/index.js"
export default {
	data() {
		return {
			bg_image,
			data: {},
			type: '1',
			id: null,
			options:{},//页面参数
		}
	},
	onLoad(options) {
		this.options = options
		this.fetchSomething(options)
	},
	onPullDownRefresh(){//页面下拉刷新
		this.fetchSomething(this.options)
		uni.stopPullDownRefresh();
	},
	methods: {
		async fetchSomething(options){
			this.type = options.type
			this.id = options.id
			this.getDetailByType()
		},
		previewImage(urls) {
			uni.previewImage({
				urls
			});
		},
		async getDetailByType() {
			//室内
			if (this.type === '1') {
				let res = await indoorRecordDetail(this.id)
				this.data = res.data || {}
			} else {
				//路侧
				let res = await outdoorRecordDetail(this.id)
				this.data = res.data || {}
			}

		},
		copy() {
			let text = this.data.orderId
			// #ifdef H5
			let textarea = document.createElement("textarea")
			textarea.value = text
			textarea.readOnly = "readOnly"
			document.body.appendChild(textarea)
			textarea.select() // 选中文本内容
			textarea.setSelectionRange(0, text.length)
			uni.showToast({ //提示
				title: '复制成功',
				icon: 'success'
			})
			document.execCommand("copy")
			textarea.remove()
			// #endif
			// #ifndef H5
			uni.setClipboardData({
				data: text, //要被复制的内容
				success: () => { //复制成功的回调函数
					uni.showToast({ //提示
						title: `复制成功`,
						icon: 'success'
					})
				}
			}, true);
			// #endif
		},
	}
}